﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChoViet.Model;
namespace ChoViet.CMS.Models
{
    public class BaseUserManager
    {
        protected string CurrentUserName
        {
            get
            {
                IFormsAuthenticationService iform = new FormsAuthenticationService();
                string strUserName = iform.GetCurrentUserName();
                return strUserName == null ? string.Empty : strUserName;
            }
        }
        private int? CurentUserId
        {
            get
            {
                User us = CurrentUser;

                return us == null ? 0 : us.ID;
            }
        }
        public User CurrentUser
        {
            get
            {
                string userName = CurrentUserName;

                if (!string.IsNullOrEmpty(userName))
                {
                    ChoVietDataContext edt = new ChoVietDataContext();
                    var us = edt.Users.FirstOrDefault(e => e.UserName == userName);
                    return us;
                }
                return null;
            }
        }
    }
}
